package ve.basura.entrada.util;

import java.util.HashMap;
import java.util.List;
import java.util.Properties;

import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.springframework.beans.factory.annotation.Autowired;

import com.aseo.business.hibernate.ChoferManager;
import com.aseo.business.hibernate.VehiculoManager;
import com.aseo.model.entity.hibernate.Vehiculo;

import ve.basura.entrada.main.EntradaMain;


public class EntradaSalidaUtil {

	/**
	 * Mapa que contiene todas las imagenes del aplicativo 
	 */
	HashMap<String, Image> imagesMap = new HashMap<String, Image>();
	
	/**
	 * Properties que contiene todas las etiquetas del aplicativo
	 */
	Properties labels = null; 
	
	/**
	 * Properties que contiene los parametros de configuracion de la aplicacion
	 */
	Properties config = null; 
	
	
	public EntradaSalidaUtil(){
		
	}
	
	/**
	 * Constructor
	 * 
	 * @param display
	 * @param labels
	 * @param config
	 */
	public EntradaSalidaUtil(Display display, Properties labels, Properties config){
		
		this.labels = labels ; 
		this.config = config ;
		
		//Seleccion Chofer Dialog
		Image seleccionChoferDialog_buttonAcceptImage = new Image(display, EntradaMain.class.getResourceAsStream("resources/images/accept.png"));
		Image seleccionChoferDialog_columnUserImage = new Image(display, EntradaMain.class.getResourceAsStream("resources/images/user.png")); 
		Image seleccionChoferDialog_columnCodigoImage = new Image(display, EntradaMain.class.getResourceAsStream("resources/images/code.png")); 
		
		//Seleccion Vehiculo Dialog
		Image seleccionVehiculoDialog_columnPlacaImage = new Image(display,EntradaMain.class.getResourceAsStream("resources/images/placa.png"));
		Image seleccionVehiculoDialog_columnDescripcionImage = new Image(display,EntradaMain.class.getResourceAsStream("resources/images/descripcion.png")); 
		
		//Entrada Main 
		Image entradaMain_splashImage = new Image(display, EntradaMain.class.getResourceAsStream("resources/images/splash.png"));
		Image window_ApplicationIcon = new Image(display, EntradaMain.class.getResourceAsStream("resources/images/aplicationicon.png"));
				
		//Window
		Image window_vehiculoImage = new Image(display, EntradaMain.class.getResourceAsStream("resources/images/vehiculo.png"));
		Image window_delete = new Image (display, EntradaMain.class.getResourceAsStream("resources/images/delete.png"));
		Image window_check = new Image(display, EntradaMain.class.getResourceAsStream("resources/images/check.png"));
		Image window_searchImage = new Image(display, EntradaMain.class.getResourceAsStream("resources/images/search.png"));

		
		//entrada main images
		imagesMap.put("splashImage", entradaMain_splashImage);
		imagesMap.put("applicationIcon", window_ApplicationIcon);
		
		//window images
		imagesMap.put("vehiculoImage", window_vehiculoImage);
		imagesMap.put("deleteImage", window_delete );
		imagesMap.put("checkImage", window_check);
		imagesMap.put("searchImage",window_searchImage);
		
		//dialog chofer images
		imagesMap.put("acceptImage", seleccionChoferDialog_buttonAcceptImage);
		imagesMap.put("userImage", seleccionChoferDialog_columnUserImage);
		imagesMap.put("codeImage",seleccionChoferDialog_columnCodigoImage);
	
		//dialog vehiculo images
		imagesMap.put("placaImage", seleccionVehiculoDialog_columnPlacaImage);
		imagesMap.put("descripcionImage",seleccionVehiculoDialog_columnDescripcionImage );
		
	}

	/**
	 * @param num String a verificar si es un numero 
	 * 
	 */
	public boolean isIntNumber(String num){
		try{
			Integer.parseInt(num);
		} catch(NumberFormatException nfe) {
			return false;
		}
		return true;
	}

	/**
	 * @return the imagesMap
	 */
	public HashMap<String, Image> getImagesMap() {
		return imagesMap;
	}
	
	/**
	 * 
	 * @param property
	 * @return La propiedad del properties de labels
	 * 
	 */
	public String getProperty(String property){
		return labels.getProperty(property);
	}

	/**
	 * 
	 * @param property
	 * @return La propiedad del properties de configuracion
	 * 
	 */
	public String getConfigProperty(String property){
		return config.getProperty(property);
	}
	
}
